package com.admin.his.config;

import java.util.ArrayList;
import java.util.List;

import com.admin.his.config.interceptor.UserContextInteceptor;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;

@Component
public class MVCConfigration implements WebMvcConfigurer {

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
	
		registry.addInterceptor(new UserContextInteceptor())
		.addPathPatterns("/api/**");
	}

	@Override
	public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
		FastJsonHttpMessageConverter converter=new FastJsonHttpMessageConverter();
		converter.setSupportedMediaTypes(new ArrayList<MediaType>() {{
			add(MediaType.APPLICATION_JSON_UTF8);
		}	
		});
		
		converters.add(converter);
		
		
		
	}
}
